package com.dapeis.core.utils.json;

import java.lang.reflect.Type;
import java.util.Date;

import com.ag.module.common.api.domain.NoticePush;
import com.ag.utils.DateUtils;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

public class NoticePushGsonAdapter implements JsonSerializer<NoticePush> {

    @Override
    public JsonElement serialize(NoticePush src, Type typeOfSrc,
	    JsonSerializationContext context) {
	JsonObject json = new JsonObject();
	json.addProperty("id", src.getId());
	json.addProperty("title", src.getThumbTitle());
	json.addProperty("content", src.getContent());
	json.addProperty(
		"CreateTime",
		DateUtils.format(DateUtils.YYYY_MM_DD_HH_MM_SS,
			new Date(src.getRecordCreateTime() * 1000)));
	json.addProperty("url", src.getUrl());
	json.addProperty("data", src.getData());
	return json;
    }

}
